package Snacks.sevlect;

import Snacks.entiy.Snacks;
import Snacks.sevise.SnacksServise;
import Snacks.sevise.impl.SnacksSerImpl;
import com.alibaba.fastjson.JSON;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

@WebServlet("/ServletLoginLike")
public class ServletLoginLike extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("UTF-8");
        response.setCharacterEncoding("UTF-8");

        String name=request.getParameter("name");

        SnacksServise ss=new SnacksSerImpl();

        List<Snacks> list= ss.getLike(name);

        PrintWriter out=response.getWriter();
        out.print(JSON.toJSONString(list));

    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request,response);
    }
}
